//
//  StatusTopView.swift
//  MyWeibo
//
//  Created by tanchao on 15/8/6.
//  Copyright © 2015年 chaoren. All rights reserved.
//

import UIKit
import SDWebImage
class StatusTopView: UIView {

    var status:Status?{
        didSet{
            if let url = status?.user?.imageUrl{
                iconView.sd_setImageWithURL(url)
            }
            vipIconVIew.image = status?.user?.vipImage
            memIconView.image = status?.user?.memImage
            nameLabel.text = status?.user?.name ?? ""
            //            TODO: 设置发布时间和微博来源
            timeLabel.text = "刚刚"
            saurceLabel.text = "来自 weibo.com"
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUpUI()
        
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    private func setUpUI(){
        let spView = UIView()
        spView.backgroundColor = UIColor(white: 0.8, alpha: 1.0)
        addSubview(spView)
        spView.ff_AlignInner(type: ff_AlignType.TopLeft, referView: self, size: CGSize(width: UIScreen.mainScreen().bounds.width, height: StatusCellControlMargin))
        addSubview(iconView)
        iconView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: spView, size: CGSize(width: 35, height: 35), offset: CGPoint(x: StatusCellControlMargin, y: StatusCellControlMargin))
        addSubview(vipIconVIew)
        vipIconVIew.ff_AlignInner(type: ff_AlignType.BottomRight, referView: iconView, size: nil, offset: CGPoint(x: StatusCellControlMargin, y: StatusCellControlMargin))
        addSubview(nameLabel)
        nameLabel.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: iconView, size: nil, offset: CGPoint(x: StatusCellControlMargin, y: 0))
        addSubview(memIconView)
        memIconView.ff_AlignHorizontal(type: ff_AlignType.CenterRight, referView: nameLabel, size: nil, offset: CGPoint(x: StatusCellControlMargin, y: 0))
        addSubview(timeLabel)
        timeLabel.ff_AlignHorizontal(type: ff_AlignType.BottomRight, referView: iconView, size: nil, offset: CGPoint(x: StatusCellControlMargin, y: 0))
        addSubview(saurceLabel)
        saurceLabel.ff_AlignHorizontal(type: ff_AlignType.CenterRight, referView: timeLabel, size: nil, offset: CGPoint(x: StatusCellControlMargin, y: 0))
        
    }
 /// 用户头像
    lazy private  var iconView : UIImageView = UIImageView()
 /// 用户名称
    lazy private  var nameLabel : UILabel = UILabel(text_Color: UIColor.darkGrayColor(), font_Size: 14)
 /// 时间标签
    lazy private var timeLabel : UILabel = UILabel(text_Color: UIColor.orangeColor(), font_Size: 9)
 /// 来源标签
    lazy private var saurceLabel : UILabel = UILabel(text_Color: UIColor.lightGrayColor(), font_Size: 9)
 /// 会员图标
    lazy private var memIconView : UIImageView = UIImageView()
 /// Vip图标
    lazy private var vipIconVIew : UIImageView = UIImageView()

}
